﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for XLDL
/// </summary>
public class XLDL
{
    //SqlConnection("Data Source=.\\SQL28;AttachDbFilename= FASHIONSTYLE.mdf;User id = sa; password=123");
    static string StrCnn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
    public static DataTable Docbang(string LenhSQL)
    {
        using (SqlConnection cnn = new SqlConnection(StrCnn))
        {
            SqlDataAdapter bodocghi = new SqlDataAdapter(LenhSQL, cnn);
            DataTable bang = new DataTable();
            bodocghi.Fill(bang);
            return bang;
        }
    }
    public static void thuchienlenh(string LenhSQL)
    {
        using (SqlConnection cnn = new SqlConnection(StrCnn))
        {
            cnn.Open();
            SqlCommand bolenh = new SqlCommand(LenhSQL, cnn);
            bolenh.ExecuteNonQuery();
            cnn.Close();
        }
    }
    public static string Getdata(String LenhSQL)
    {
        using (SqlConnection cnn = new SqlConnection(StrCnn))
        {
            cnn.Open();
            SqlCommand cmd = cnn.CreateCommand();
            cmd.CommandText = LenhSQL;
            string result = "" + cmd.ExecuteScalar().ToString();
            cnn.Close();
            return result;
        }
    }
}
